package server;

import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.net.*;
import java.util.HashMap;

public class ObjectSendThread extends Thread {
	private Socket s;
	private HashMap<String, String> map;

	public ObjectSendThread(Socket s) {
		// TODO 自动生成的构造函数存根_
		this.s = s;
		this.map = new HashMap<String, String>();
		map.put("top1", "张洋");
		map.put("江南第二帅哥", "汪翰林");
		map.put("江北第一帅哥", "王浩冰");
	}

	@Override
	public void run() {
		System.out.println("准备给" + s + "发送文件！");

		// InputStream in = s.getInputStream();
		// OutputStream out = s.getOutputStream();
		try {
			ObjectOutputStream oout = new ObjectOutputStream(
					s.getOutputStream());
			oout.writeObject(map);
			// >oout.reset();
			System.out.println("发送" + s + "结束");
		} catch (IOException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		} finally {
			try {
				s.close();
			} catch (IOException e) {
				// TODO 自动生成的 catch 块
				e.printStackTrace();
			}
		}

	}
}
